<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: Sifteo::MotionIterator Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>Sifteo</b></li><li class="navelem"><a class="el" href="class_sifteo_1_1_motion_iterator.html">MotionIterator</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="class_sifteo_1_1_motion_iterator-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Sifteo::MotionIterator Class Reference<div class="ingroups"><a class="el" href="group__motion.html">Motion</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Utility for reading low-level motion events from a <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>.  
 <a href="class_sifteo_1_1_motion_iterator.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="motion_8h_source.html">sifteo/motion.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a8f6ed014841821a14f6a7afd4691e8b1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__math.html#gaec7afb90b5c1db8751abaf5f0406f6b7">Byte3</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a8f6ed014841821a14f6a7afd4691e8b1">accel</a> () const </td></tr>
<tr class="memdesc:a8f6ed014841821a14f6a7afd4691e8b1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the acceleration sample at the iterator's current position.  <a href="#a8f6ed014841821a14f6a7afd4691e8b1">More...</a><br/></td></tr>
<tr class="separator:a8f6ed014841821a14f6a7afd4691e8b1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66f30108237da8211fe752c3ac75cfd7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a66f30108237da8211fe752c3ac75cfd7">adjustTicks</a> (int32_t value)</td></tr>
<tr class="memdesc:a66f30108237da8211fe752c3ac75cfd7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Add a value to the tick counter.  <a href="#a66f30108237da8211fe752c3ac75cfd7">More...</a><br/></td></tr>
<tr class="separator:a66f30108237da8211fe752c3ac75cfd7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a882725558803ac1a867884b3caf5ac04"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a882725558803ac1a867884b3caf5ac04">MotionIterator</a> (_SYSMotionBuffer *buffer)</td></tr>
<tr class="memdesc:a882725558803ac1a867884b3caf5ac04"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a new <a class="el" href="class_sifteo_1_1_motion_iterator.html" title="Utility for reading low-level motion events from a MotionBuffer.">MotionIterator</a>, attached to the provided <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>.  <a href="#a882725558803ac1a867884b3caf5ac04">More...</a><br/></td></tr>
<tr class="separator:a882725558803ac1a867884b3caf5ac04"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a75d3fc9b9195471633bbba23ba6f073f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a75d3fc9b9195471633bbba23ba6f073f">next</a> ()</td></tr>
<tr class="memdesc:a75d3fc9b9195471633bbba23ba6f073f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Advance to the next motion sample, if possible.  <a href="#a75d3fc9b9195471633bbba23ba6f073f">More...</a><br/></td></tr>
<tr class="separator:a75d3fc9b9195471633bbba23ba6f073f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa00a582bf0894567de939963d7ac08e8"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#aa00a582bf0894567de939963d7ac08e8">seconds</a> () const </td></tr>
<tr class="memdesc:aa00a582bf0894567de939963d7ac08e8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the timestamp at the iterator's current position, in seconds.  <a href="#aa00a582bf0894567de939963d7ac08e8">More...</a><br/></td></tr>
<tr class="separator:aa00a582bf0894567de939963d7ac08e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a866ccb3bd10c912b1c89ea9f8630e4f2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a866ccb3bd10c912b1c89ea9f8630e4f2"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a866ccb3bd10c912b1c89ea9f8630e4f2">setTicks</a> (uint32_t value)</td></tr>
<tr class="memdesc:a866ccb3bd10c912b1c89ea9f8630e4f2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modify the tick counter. <br/></td></tr>
<tr class="separator:a866ccb3bd10c912b1c89ea9f8630e4f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1758a6f74aad260ba383a922d767c8ed"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a1758a6f74aad260ba383a922d767c8ed">ticks</a> () const </td></tr>
<tr class="memdesc:a1758a6f74aad260ba383a922d767c8ed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the timestamp at the iterator's current position, in ticks.  <a href="#a1758a6f74aad260ba383a922d767c8ed">More...</a><br/></td></tr>
<tr class="separator:a1758a6f74aad260ba383a922d767c8ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr class="memitem:a93e83ec89228d149dcb407bd25c9f5eb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a93e83ec89228d149dcb407bd25c9f5eb"></a>
static const unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a93e83ec89228d149dcb407bd25c9f5eb">TICK_HZ</a> = <a class="el" href="struct_sifteo_1_1_motion_buffer.html">MotionBuffer</a>&lt;&gt;::TICK_HZ</td></tr>
<tr class="memdesc:a93e83ec89228d149dcb407bd25c9f5eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reciprocal of the <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>'s timestamp unit, in Hertz. <br/></td></tr>
<tr class="separator:a93e83ec89228d149dcb407bd25c9f5eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5aaf945e7904fc4914c1b6bd82aa8f70"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5aaf945e7904fc4914c1b6bd82aa8f70"></a>
static const unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#a5aaf945e7904fc4914c1b6bd82aa8f70">TICK_NS</a> = <a class="el" href="struct_sifteo_1_1_motion_buffer.html">MotionBuffer</a>&lt;&gt;::TICK_NS</td></tr>
<tr class="memdesc:a5aaf945e7904fc4914c1b6bd82aa8f70"><td class="mdescLeft">&#160;</td><td class="mdescRight">Duration of the <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>'s timestamp unit, in nanoseconds. <br/></td></tr>
<tr class="separator:a5aaf945e7904fc4914c1b6bd82aa8f70"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac777f2c43b6f36d8c888dcc18d213e45"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac777f2c43b6f36d8c888dcc18d213e45"></a>
static const unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_motion_iterator.html#ac777f2c43b6f36d8c888dcc18d213e45">TICK_US</a> = <a class="el" href="struct_sifteo_1_1_motion_buffer.html">MotionBuffer</a>&lt;&gt;::TICK_US</td></tr>
<tr class="memdesc:ac777f2c43b6f36d8c888dcc18d213e45"><td class="mdescLeft">&#160;</td><td class="mdescRight">Duration of the <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>'s timestamp unit, in microseconds. <br/></td></tr>
<tr class="separator:ac777f2c43b6f36d8c888dcc18d213e45"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Utility for reading low-level motion events from a <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>. </p>
<p>This object keeps track of the state necessary to extract a stream of motion events from a <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>. It manages the FIFO head pointer, and keeps track of the current time.</p>
<p>After it is created, the iterator has an indeterminate state. It may be advanced to the next available motion sample with <a class="el" href="class_sifteo_1_1_motion_iterator.html#a75d3fc9b9195471633bbba23ba6f073f" title="Advance to the next motion sample, if possible.">next()</a>. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a882725558803ac1a867884b3caf5ac04"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Sifteo::MotionIterator::MotionIterator </td>
          <td>(</td>
          <td class="paramtype">_SYSMotionBuffer *&#160;</td>
          <td class="paramname"><em>buffer</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Construct a new <a class="el" href="class_sifteo_1_1_motion_iterator.html" title="Utility for reading low-level motion events from a MotionBuffer.">MotionIterator</a>, attached to the provided <a class="el" href="struct_sifteo_1_1_motion_buffer.html" title="A memory buffer which holds captured motion data.">MotionBuffer</a>. </p>
<p>The read pointer is initialized to be equal to the system's write pointer, meaning that <a class="el" href="class_sifteo_1_1_motion_iterator.html#a75d3fc9b9195471633bbba23ba6f073f" title="Advance to the next motion sample, if possible.">next()</a> will return false until the first new acceleration sample is collected after this iterator has been constructed. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a8f6ed014841821a14f6a7afd4691e8b1"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__math.html#gaec7afb90b5c1db8751abaf5f0406f6b7">Byte3</a> Sifteo::MotionIterator::accel </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the acceleration sample at the iterator's current position. </p>
<p>The units and coordinate system are identical to that of <a class="el" href="struct_sifteo_1_1_cube_i_d.html#a6da5d2ed7096f343f921b2a879c54e80" title="Return the physical accelerometer state, as a signed byte-vector.">CubeID::accel()</a>. </p>

</div>
</div>
<a class="anchor" id="a66f30108237da8211fe752c3ac75cfd7"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Sifteo::MotionIterator::adjustTicks </td>
          <td>(</td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>value</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Add a value to the tick counter. </p>
<p>This helps with use cases where you'd like to use the tick counter as an accumulator for sample rate conversion. If you want to collect a sample every N ticks, for example, you can wait until <a class="el" href="class_sifteo_1_1_motion_iterator.html#a1758a6f74aad260ba383a922d767c8ed" title="Return the timestamp at the iterator&#39;s current position, in ticks.">ticks()</a> is at least N, then use adjustTicks(-N) to remove that span of time from the accumulator. </p>

</div>
</div>
<a class="anchor" id="a75d3fc9b9195471633bbba23ba6f073f"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Sifteo::MotionIterator::next </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Advance to the next motion sample, if possible. </p>
<p>If another sample is available, advances to it and returns true. If no more samples are ready, returns false. </p>

</div>
</div>
<a class="anchor" id="aa00a582bf0894567de939963d7ac08e8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">float Sifteo::MotionIterator::seconds </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the timestamp at the iterator's current position, in seconds. </p>
<p>This is like <a class="el" href="class_sifteo_1_1_motion_iterator.html#a1758a6f74aad260ba383a922d767c8ed" title="Return the timestamp at the iterator&#39;s current position, in ticks.">ticks()</a>, except we scale the result to seconds, and return it as a floating point number. Note that this has less precision than <a class="el" href="class_sifteo_1_1_motion_iterator.html#a1758a6f74aad260ba383a922d767c8ed" title="Return the timestamp at the iterator&#39;s current position, in ticks.">ticks()</a>, and there is no good way to handle roll-over, so it should only be used if you know you won't be sampling data for a very long period of time. </p>

</div>
</div>
<a class="anchor" id="a1758a6f74aad260ba383a922d767c8ed"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t Sifteo::MotionIterator::ticks </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the timestamp at the iterator's current position, in ticks. </p>
<p>This timestamp starts out at zero, and increases at each call to <a class="el" href="class_sifteo_1_1_motion_iterator.html#a75d3fc9b9195471633bbba23ba6f073f" title="Advance to the next motion sample, if possible.">next()</a>. It is a 32-bit counter, in units of ticks as described by TICK_NS, TICK_US, and TICK_HZ.</p>
<p>This timestamp counter will roll over after approximately 12 days. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="motion_8h_source.html">motion.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
